package com.magina.antiPro.util;

/**
 * 此枚举可以实现getName(code)
 * 例子:丢失原因
 */
public enum LossReason {
    REASON_1("偏远地区",1),
    REASON_2("第三方改造",2),
    REASON_3("M3代理商竞争",3),
    REASON_4("存在COC问题",4),
    REASON_5("别墅梯",5),
    REASON_6("客户欠款",6),
    REASON_7("第三方框架协议",7),
    REASON_8("NI质量",8),
    REASON_9("DC代理商竞争",9),
    REASON_10("电梯停运",10),
    REASON_11("存在安全问题",11),
    REASON_12("低价竞争",12),
    REASON_13("EI质量",13),
    REASON_14("无法满足当地保养法规",14),
    REASON_15("电梯拆除",15),
    REASON_16("客户自保",16),
    REASON_17("合同条款或客户流程",17);

    private String name;
    private Integer code;
    LossReason(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public static String getName(Integer code) {
        for (LossReason riskReason : LossReason.values()) {
            if (riskReason.getCode().intValue() == code.intValue()) {
                return riskReason.getName();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return this.name;
    }
}
